<?php

/**
 * *******************************************************************************
 * Class DocTypes - Document Types management 
 * *******************************************************************************
 * @author $Author: damien.viguier@gmail.com $
 * @version $Rev: 33 $
 * @internal $Id: DocTypes.class.php 33 2013-08-25 15:15:32Z damien.viguier@gmail.com $
 * @internal $LastChangedDate: 2013-08-25 15:15:32 +0000 (Sun, 25 Aug 2013) $
 * @link $HeadURL: http://personal-ged.googlecode.com/svn/trunk/webroot/ajax/data/class/DocTypes.class.php $
 * *******************************************************************************
 */

include_once '../../../lib/DBManagement.class.php';

class DocTypes {
	/**
	 * Return a table with all Attributes definition regarding DocTypeCode parameter
	 * @static
	 * @param String $p_s_codeDocType
	 * @return array(array(mixed)) Table of AttrituesDocType Definition 
	 */
	static function getAllAttributesDefByDocTypeID($p_s_codeDocType)
	{
		/*
			SELECT
				DOCTYPE_CODE,
				DOCTYPEATTRDEF_ID,
				ATTR_LNGLABEL,
				ATTR_SHTLABEL,
				ATTR_IS_MULTIPLE,
				ATTR_IS_FROM_LIST,
				ATTR_IS_FREE,
				ATTR_IS_MANDATORY,
				ATTR_FORMAT,
				ATTR_FORMAT_PATTERN,
				LST_CODE,
				LST_VALUES_CNT
			FROM VW_DOCTYPES_ATTRDEF WHERE DOCTYPE_CODE = $p_s_codeDocType ORDER BY DOCTYPEATTRDEF_ID ASC;

		*/
		
		$l_s_sql = "SELECT
						DOCTYPE_CODE,
						DOCTYPEATTRDEF_ID,
						ATTR_LNGLABEL,
						ATTR_SHTLABEL,
						ATTR_IS_MULTIPLE,
						ATTR_IS_FROM_LIST,
						ATTR_IS_FREE,
						ATTR_IS_MANDATORY,
						ATTR_FORMAT,
						ATTR_FORMAT_PATTERN,
						LST_CODE,
						LST_VALUES_CNT
					FROM VW_DOCTYPES_ATTRDEF 
					WHERE 
						DOCTYPE_CODE = '".$p_s_codeDocType."' ";
		
		$l_as_results = DBManagement::query($l_s_sql);
		return $l_as_results;
	}
	/**
	 * Return a list with all DocTypes data
	 *
	 * @static
	 * @return array(array(mixed))
	 */
	static function getAllDocTypes()
	{
		/*
			SELECT
				`VW_DOCTYPES`.`DOCTYPE_CODE`,
				`VW_DOCTYPES`.`DOCTYPE_LABEL`,
				`VW_DOCTYPES`.`DOCTYPE_DESCRIPTION`,
				`VW_DOCTYPES`.`DOCTYPE_ATTR_CNT`,
				`VW_DOCTYPES`.`DOCTYPE_DOC_CNT`
			FROM `pged`.`VW_DOCTYPES`;
		*/
		$l_s_sql = "SELECT
						`DOCTYPE_CODE`,
						`DOCTYPE_LABEL`,
						`DOCTYPE_DESCRIPTION`,
						`DOCTYPE_ATTR_CNT`,
						`DOCTYPE_DOC_CNT`
					FROM `VW_DOCTYPES` ;";
		$l_as_results = DBManagement::query($l_s_sql);
		return $l_as_results;
	}
	
	static function getAllListValuesByID($p_s_codeList)
	{
		/* 	SELECT
				LST_CODE_VALUE,
				LST_VALUE,
				LST_USEDBY_ATTRDEF,
				LST_USEDBY_DOCTYPES
			FROM VW_LISTVALUES_ATTRDEF; 
		*/
		$l_s_sql = "SELECT
						LST_CODE_VALUE,
						LST_VALUE,
						LST_USEDBY_ATTRDEF,
						LST_USEDBY_DOCTYPES
					FROM VW_LISTVALUES_ATTRDEF
				 	WHERE LST_CODE_VALUE = '".$p_s_codeList."';";
		$l_as_results = DBManagement::query($l_s_sql);
		return $l_as_results;
	}
	
}

?>